package com.atguigu.gulimail.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class OrderConfirmVo {
    @Getter @Setter
    List<MemberAddressVo> address;

    @Getter @Setter
    List<OrderItemVo> items;

    @Getter @Setter
    Integer integration;

    @Getter @Setter
    Map<Long, Boolean> stocks;

    @Getter @Setter
    String orderToken;
//    BigDecimal total;
//    BigDecimal payPrice;

    public Integer getCount() {
        Integer num = 0;
        if (items != null)
            for (OrderItemVo item : items) {
                num += item.getCount();
            }
        return num;
    }

    public BigDecimal getTotal() {
        BigDecimal bigDecimal = new BigDecimal(0);
        if (items != null)
        for (OrderItemVo item : items) {
            bigDecimal = bigDecimal.add(item.getPrice().multiply(BigDecimal.valueOf(item.getCount())));
        }
        return bigDecimal;
    }

    public BigDecimal getPayPrice() {
        return getTotal();
    }
}
